const {insertData} = require('./common');
const {particulars} = require('../../xiangqing/shangpinxiangqing');

(async () => {
    let arr = await insertData('iphones').then(async model => {
        let data = await new Promise(resolve => {
            model.findData({
                obj: {},
                obj_1: {id: true},
                callback(err, doc) {
                    if (err) {
                        console.log(err);
                        return;
                    }
                    let arr = doc;
                    resolve(arr);
                }
            })
        })
        return data
    })

    let dataArr = await particulars()

    insertData('phonetinfos').then( model => {
        dataArr.forEach((item,index) => {
            model.create({
                iphome:item,
                id: arr[index],
                sort: index
            })
        })
    })
})()



